using System;
using System.Collections.Generic;
using System.Text;
using CommonTypes.Math;

namespace BuildingBasicDomain
{
    # region "Modification Block"

    public class GeometryWorkBench
    {
        public static List<ILine> UniformLines(IPoint p1, Vector3D vector, int spaceN, int spaceS, double length)
        {
            Vector3D initVector = new Vector3D(vector);
            List<ILine> lines = new List<ILine>();

            vector.RotateY(90);
            Matrix3D scale = new Matrix3D(spaceN, 0, 0, 0, 1, 0, 0, 0, spaceN);

            vector = scale * vector + p1.V;

            Vector3D v1 = p1.V;
            Vector3D vline, vend, vstrt;

            int divisions = 15;
            double step;
            step = (length / divisions);
            vline = initVector;

            scale = new Matrix3D(length / 2, 0, 0, 0, 1, 0, 0, 0, length / 2);

            vend = v1 + scale * vline;
            vstrt = v1 - scale * vline;

            // vector.Normalize();
            scale = new Matrix3D(spaceS, 0, 0, 0, 1, 0, 0, 0, spaceS);
            vector = scale * vector;
            //v3.Normalize ();

            IPoint pStart;
            IPoint pEnd;


            for (int j = 0; j < divisions - 1; j++)
            {
                scale = new Matrix3D(1, 0, 0, 0, 0, 0, 0, 0, 1);
                v1 = scale * v1;
                vend = scale * vend;
                vstrt = scale * vstrt;

                scale = new Matrix3D(step, 0, 0, 0, 1, 0, 0, 0, step);

                vstrt = vstrt + scale * vector;
                pStart = new Point(vstrt.X, vstrt.Y, vstrt.Z);
                vend = vend + scale * vector;
                pEnd = new Point(vend.X, vend.Y, vend.Z);

                lines.Add(new Line(pStart, pEnd));
            }
            return lines;

        }
      
        public static List<ILine> UniformLines(IPoint p1, Vector3D vectorX, Vector3D vectorY, double lengthX, double lenghtY , int divisions)
        {
          // Vector3D initVector = new Vector3D(vectorX);
            List<ILine> lines = new List<ILine>();

            double step;
            step = (lenghtY / divisions);

            IPoint pStart;
            IPoint pEnd;
            Vector3D vstrt , vend;

            for (int j = 0; j < divisions+1; j++)
            {
                vstrt = j * step * vectorY + p1.V;
                pStart = (Point)vstrt;
                vend = vstrt + vectorX*lengthX;
                pEnd = (Point)vend;

                lines.Add(new Line(pStart, pEnd));
            }
            return lines;

        }
          /* * */

    }



    public interface IPlaneModification
    {
        bool splitPlane(ILine line);
        bool splitPlane(IPlane plane);

        bool extendPlane(ILine line);
        bool extendPlane(IPlane plane);

        bool trimPlane(ILine line);
        bool trimPlane(IPlane plane);
    }

    #endregion
}
